<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script>
        function func1() {
            {#var obj = document.getElementById('d1');#}
            {#obj.innerHTML = 'zhang3';#}

            var xhr = new XMLHttpRequest();

            xhr.open('post', '/dosearch/');

            xhr.send();

            {# 当请求得到响应，并将处理的数据返回时，执行function中定义的函数 #}
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200 || xhr.status == 304) {
                        ret = JSON.parse(xhr.responseText);

                        console.log(ret.name);
                        console.log(ret.age);

                        document.getElementById('d1').innerHTML = ret.name;
                        document.getElementById('d2').innerHTML = ret.age;

                    }
                }
            }


        }
    </script>

</head>
<body>
<div>
    <input type="text" value="aaa">
    <input type="password" value="bbb">
    <input type="radio">男

    <input type="checkbox">游戏
    <input type="checkbox">编程

</div>

<div>
    <form action="#" method="post">
        <input type="text" name="name">
        <button type="button" onclick="func1()">查询</button>
        {#        <input type="submit" value="查询">#}
    </form>
</div>


<div id="d1">{{ name }}</div>
<div id="d2">{{ age }}</div>

</body>
</html>